// MESSAGE ATTITUDE_BEAM support class

#pragma once

namespace mavlink {
namespace fppa {
namespace msg {

/**
 * @brief ATTITUDE_BEAM message
 *
 * Status of secondary AHRS filter if available.
 */
struct ATTITUDE_BEAM : mavlink::Message {
    static constexpr msgid_t MSG_ID = 14;
    static constexpr size_t LENGTH = 85;
    static constexpr size_t MIN_LENGTH = 85;
    static constexpr uint8_t CRC_EXTRA = 174;
    static constexpr auto NAME = "ATTITUDE_BEAM";


    uint64_t time_boot_ms; /*< [ms] Timestamp (time since system boot). */
    float rx_polar; /*< [deg] Polar angle.(-90.0..90.0)(deg) */
    float rx_pitch; /*< [deg] Pitch angle.(-90.0..90.0)(deg) */
    float rx_yaw; /*< [deg] Yaw angle.(-180.0..180.0)(deg) */
    float rx_T; /*< [deg] T angle.(0.0..51.0)(deg) */
    float rx_ap; /*< [deg] AP angle.(0.0..60.0)(deg) */
    float rx_theta; /*< [deg] theta angle.(5.0..80.0)(deg) */
    float rx_phi; /*< [deg] Yaw angle.(170.0..250.0)(deg) */
    float tx_polar; /*< [deg] Polar angle.(-90.0..90.0)(deg) */
    float tx_pitch; /*< [deg] Pitch angle.(-90.0..90.0)(deg) */
    float tx_yaw; /*< [deg] Yaw angle.(-180.0..180.0)(deg) */
    float tx_T; /*< [deg] T angle.(0.0..51.0)(deg) */
    float tx_ap; /*< [deg] AP angle.(0.0..60.0)(deg) */
    float tx_theta; /*< [deg] theta angle.(5.0..80.0)(deg) */
    float tx_phi; /*< [deg] Yaw angle.(170.0..250.0)(deg) */
    float omega_x; /*< [deg/sec] angular velocity at x axis */
    float omega_y; /*< [deg/sec] angular velocity at y axis */
    float omega_z; /*< [deg/sec] angular velocity at z axis */
    uint8_t mode; /*<  Current mode */
    float rx_freq; /*< [mhz] receive antenna frequency. */
    float tx_freq; /*< [mhz] transmit antenna frequency. */


    inline std::string get_name(void) const override
    {
            return NAME;
    }

    inline Info get_message_info(void) const override
    {
            return { MSG_ID, LENGTH, MIN_LENGTH, CRC_EXTRA };
    }

    inline std::string to_yaml(void) const override
    {
        std::stringstream ss;

        ss << NAME << ":" << std::endl;
        ss << "  time_boot_ms: " << time_boot_ms << std::endl;
        ss << "  rx_polar: " << rx_polar << std::endl;
        ss << "  rx_pitch: " << rx_pitch << std::endl;
        ss << "  rx_yaw: " << rx_yaw << std::endl;
        ss << "  rx_T: " << rx_T << std::endl;
        ss << "  rx_ap: " << rx_ap << std::endl;
        ss << "  rx_theta: " << rx_theta << std::endl;
        ss << "  rx_phi: " << rx_phi << std::endl;
        ss << "  tx_polar: " << tx_polar << std::endl;
        ss << "  tx_pitch: " << tx_pitch << std::endl;
        ss << "  tx_yaw: " << tx_yaw << std::endl;
        ss << "  tx_T: " << tx_T << std::endl;
        ss << "  tx_ap: " << tx_ap << std::endl;
        ss << "  tx_theta: " << tx_theta << std::endl;
        ss << "  tx_phi: " << tx_phi << std::endl;
        ss << "  omega_x: " << omega_x << std::endl;
        ss << "  omega_y: " << omega_y << std::endl;
        ss << "  omega_z: " << omega_z << std::endl;
        ss << "  mode: " << +mode << std::endl;
        ss << "  rx_freq: " << rx_freq << std::endl;
        ss << "  tx_freq: " << tx_freq << std::endl;

        return ss.str();
    }

    inline void serialize(mavlink::MsgMap &map) const override
    {
        map.reset(MSG_ID, LENGTH);

        map << time_boot_ms;                  // offset: 0
        map << rx_polar;                      // offset: 8
        map << rx_pitch;                      // offset: 12
        map << rx_yaw;                        // offset: 16
        map << rx_T;                          // offset: 20
        map << rx_ap;                         // offset: 24
        map << rx_theta;                      // offset: 28
        map << rx_phi;                        // offset: 32
        map << tx_polar;                      // offset: 36
        map << tx_pitch;                      // offset: 40
        map << tx_yaw;                        // offset: 44
        map << tx_T;                          // offset: 48
        map << tx_ap;                         // offset: 52
        map << tx_theta;                      // offset: 56
        map << tx_phi;                        // offset: 60
        map << omega_x;                       // offset: 64
        map << omega_y;                       // offset: 68
        map << omega_z;                       // offset: 72
        map << rx_freq;                       // offset: 76
        map << tx_freq;                       // offset: 80
        map << mode;                          // offset: 84
    }

    inline void deserialize(mavlink::MsgMap &map) override
    {
        map >> time_boot_ms;                  // offset: 0
        map >> rx_polar;                      // offset: 8
        map >> rx_pitch;                      // offset: 12
        map >> rx_yaw;                        // offset: 16
        map >> rx_T;                          // offset: 20
        map >> rx_ap;                         // offset: 24
        map >> rx_theta;                      // offset: 28
        map >> rx_phi;                        // offset: 32
        map >> tx_polar;                      // offset: 36
        map >> tx_pitch;                      // offset: 40
        map >> tx_yaw;                        // offset: 44
        map >> tx_T;                          // offset: 48
        map >> tx_ap;                         // offset: 52
        map >> tx_theta;                      // offset: 56
        map >> tx_phi;                        // offset: 60
        map >> omega_x;                       // offset: 64
        map >> omega_y;                       // offset: 68
        map >> omega_z;                       // offset: 72
        map >> rx_freq;                       // offset: 76
        map >> tx_freq;                       // offset: 80
        map >> mode;                          // offset: 84
    }
};

} // namespace msg
} // namespace fppa
} // namespace mavlink
